public class Wordsnake {

  public static int VALUE = 0;

  public static void main(String[] args) {
    
    String filename = args.length > 0 ? args[0] : "src/words.txt";
    Graph newGraph = new Graph(filename);
    int bufReader = newGraph.makeGraph();
    if (bufReader == -1) {
      System.out.println("Could not open the file");
      return;
    }

    System.out.println("\nBegin alg.");
    do {
      Connection maxLink = newGraph.findMaxValue(); //finds max overlap between any two words
      VALUE += Math.pow(maxLink.getValue(), 2);
      maxLink.printConnection();
      Node from = maxLink.getFromNode();
      Node to = maxLink.getToNode();
      newGraph.joinWords(from, to, maxLink.getValue());
      System.out.println("\nNumber of words = " + newGraph.nodes.size());
    } while (newGraph.nodes.size() > 1);

    System.out.println("\nFinal word = " + newGraph.nodes.get(0).getWord());
    System.out.println("\nMaximal number = " + VALUE);
  }
}